#ifndef BINANCE_REST_H
#define BINANCE_REST_H

#include <set>
#include <map>
#include <string>
#include <iostream>
#include <curl/curl.h>
#include <openssl/hmac.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/buffer.h>
#include "fmtlog.h"
#include "object.h"

class BinanceRestApi{
public:
    BinanceRestApi(std::string api_key,std::string secret_key);
    ~BinanceRestApi();
    
    std::string getSignature(const std::string& data);
    std::string UnixTimestampMills();
    std::string getSpotQuantity(const std::string& symbol);
    void send_order(const Order& order);
    void cancel_order(const std::string &symbol,const std::string& client_order_id);
    void cancel_all_order(const std::string &symbol);
    std::vector<std::string> getSymbolList();
    void allTradingPairs(std::set<std::string>& allPairs,std::vector<std::string>& allCoins);
    void getSymbolInfo(std::map<std::string, double>& symbol_info);
    void getAccountBalance(std::map<std::string,double>& coinBalance);
    std::string ListenKey(bool isPut = false);  // fasle 表示初次获取 ListenKey

private:
    std::string apiKey;
    std::string secretKey;
    static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
};

#endif // !BINANCE_REST_H
